<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>价格日历</title>

    <link type="text/css" href="./calendar_files/jquery-ui.min.css" rel="stylesheet">
    <script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui.min.js"></script>

    <script type="text/javascript" src="./calendar_files/ajaxform.js"></script>
    <script type="text/javascript" src="./calendar_files/common.js"></script>
    <!--<script type="text/javascript" src="./calendar_files/msgbox.js"></script>-->
    <!--<link type="text/css" href="./calendar_files/msgbox.css" rel="stylesheet">-->
    <!--<script>-->
        <!--window.SITEURL="/newtravel/";-->
        <!--window.PUBLICURL = "/newtravel/public/";-->
        <!--window.WEBLIST = [{"webid": 0, "webname": "\u4e3b\u7ad9"}]//网站信息数组-->
        <!--window.BACK_CURRENCY_SYMBOL = "￥";-->
        <!--window.CURRENCY_SYMBOL = "￥";-->
    <!--</script>-->
    <link type="text/css" href="./calendar_files/style.css" rel="stylesheet">
    <link type="text/css" href="./calendar_files/base.css" rel="stylesheet">
    <link type="text/css" href="./calendar_files/base2.css" rel="stylesheet">
    <!--<script type="text/javascript" src="./calendar_files/WdatePicker.js"></script>-->
    <!--<link href="skin/WdatePicker.css" rel="stylesheet" type="text/css">-->
    <!--<link href="css/WdatePicker.css" rel="stylesheet" type="text/css">-->
    <!--<script type="text/javascript" src="./calendar_files/product_add.js"></script>-->
    <!--<script type="text/javascript" src="./calendar_files/imageup.js"></script>-->
    <!--<script type="text/javascript" src="./calendar_files/jquery.validate.js"></script>-->
    <!--<link type="text/css" href="./calendar_files/uploadify.css" rel="stylesheet">-->

    <!--<script src="./calendar_files/codemirror.js" type="text/javascript" defer="defer"></script>-->
    <!--<link rel="stylesheet" type="text/css" href="./calendar_files/codemirror.css">-->

</head>
<body>
<!--景区-->
<h3>景区</h3>
<table class="content-tab">
    <tbody>
    <tr>
        <td valign="top" class="content-rt-td">
            <form method="post" name="product_frm" id="product_frm" action="submitCalendar.php">
                <div class="manage-nr">
                    <!--基础信息开始-->
                    <div class="product-add-div">
                        <div class="add-class">
                            <div class="add-class">
                                <dl>
                                    <dt>支付方式：</dt>
                                    <dd>
                                        <div class="on-off">
                                            <input type="radio" name="paytype" value="1" checked="checked">全款支付 &nbsp;
                                            <input type="radio" name="paytype" value="2">定金支付 &nbsp;
                                            <span id="dingjin" style="display: none"><input type="text" name="dingjin"
                                                                                            id="dingjintxt" value="0"
                                                                                            size="8"
                                                                                            onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-\.]+/,'');}).call(this)"
                                                                                            onblur="this.v();">&nbsp;元</span>
                                            <input type="radio" name="paytype" value="3">二次确认支付 &nbsp;
                                            <input type="radio" name="paytype" value="4">线下支付 &nbsp;
                                            <script>
                                                $("input[name='paytype']").click(function () {
                                                    if ($(this).val() == 2) {
                                                        $("#dingjin").show();
                                                    }
                                                    else {
                                                        $("#dingjin").hide()
                                                    }
                                                })
                                            </script>
                                        </div>
                                    </dd>
                                </dl>
                            </div>
                            <div class="add-class">
                                <dl>
                                    <dt>报价：</dt>
                                    <dd>
                                        <div class="price_con">
                                            <div class="price_menu">
                                                <a href="javascript:;" class="on" data-val="all">所有日期</a>
                                                <a href="javascript:;" class="" data-val="week">按星期</a>
                                                <a href="javascript:;" class="" data-val="month">按号数</a>
                                            </div>
                                            <div class="price_sub">
                                                <div>
                                                    <table class="price_tb">
                                                        <tbody>
                                                        <tr>
                                                            <td class="tit">日期范围：</td>
                                                            <td><input type="text" name="starttime"
                                                                       class="set-text-xh text_100 choosetime"
                                                                       value=""> <span class="fl">&nbsp;~&nbsp;</span>
                                                                <input type="text"
                                                                       class="set-text-xh text_100 choosetime"
                                                                       name="endtime" value=""></td>
                                                        </tr>
                                                        <tr>
                                                            <td class="tit" valign="top">价格：</td>
                                                            <td>
                                                                <!--<table class="group-tb" style="border:0px">-->
                                                                <!--<tbody>-->
                                                                <!--<tr class="group_2">-->
                                                                <!--<td>-->
                                                                <!--<span class="fl">成本</span>-->
                                                                <input type="text"
                                                                       class="set-text-xh text_100 mt-2"
                                                                       name="price"
                                                                       onkeyup="calPrice(this)" value="360"
                                                                       autocomplete="off">
                                                                <!--<span class="fl ml-10">+利润</span>-->
                                                                <!--<input type="text"-->
                                                                <!--class="set-text-xh text_60 mt-2 ml-10"-->
                                                                <!--name="profit" onkeyup="calPrice(this)"-->
                                                                <!--value="308" autocomplete="off">-->
                                                                <!--<span class="fl ml-10">售价：<b style=" color:#f60"-->
                                                                <!--class="tprice">668</b></span>-->
                                                                <!--</td>-->
                                                                <!--</tr>-->
                                                                <!--</tbody>-->
                                                                <!--</table>-->

                                                            </td>
                                                        </tr>
                                                        <!--<tr>-->
                                                            <!--<td class="tit">价格描述：</td>-->
                                                            <!--<td><input type="text" class="set-text-xh text_700 mt-2"-->
                                                                       <!--style="width: 300px" name="description" value="">-->
                                                            <!--</td>-->
                                                        <!--</tr>-->
                                                        <tr>
                                                            <td class="tit">库存：</td>
                                                            <td><input type="text" maxlength="4"
                                                                       class="set-text-xh text_100 mt-2" name="number"
                                                                       value="-1"> <span
                                                                    style="color:gray;padding-left:10px">-1表示不限</span>
                                                            </td>
                                                        </tr>
                                                        </tbody>
                                                    </table>
                                                </div>
                                                <div class="sub_item" style="display: block;">
                                                </div>
                                                <div class="sub_item" style="display: none;">
                                                    <table class="price_tb">
                                                        <tbody>
                                                        <tr>
                                                            <td>星期选择：</td>
                                                            <td>
                                                                <div class="price_week">
                                                                    <table class="day_cs" id="week_cs"
                                                                           style="display: table;">
                                                                        <tbody>
                                                                        <tr height="30px">
                                                                            <td><a href="javascript:;" val="Monday">周一</a>
                                                                            </td>
                                                                            <td val="2"><a href="javascript:;" val="Tuesday">周二</a>
                                                                            </td>
                                                                            <td val="3"><a href="javascript:;" val="Wednesday">周三</a>
                                                                            </td>
                                                                            <td val="4"><a href="javascript:;" val="Thursday">周四</a>
                                                                            </td>
                                                                            <td val="5"><a href="javascript:;" val="Friday">周五</a>
                                                                            </td>
                                                                            <td val="6"><a href="javascript:;" val="Saturday">周六</a>
                                                                            </td>
                                                                            <td val="7"><a href="javascript:;" val="Sunday">周日</a>
                                                                            </td>
                                                                        </tr>
                                                                        </tbody>
                                                                    </table>
                                                                </div>
                                                            </td>
                                                        </tr>
                                                        </tbody>
                                                    </table>
                                                </div>
                                                <div class="sub_item" style="display: none;">
                                                    <table class="price_tb">
                                                        <tbody>
                                                        <tr>
                                                            <td valign="top">日期选择：</td>
                                                            <td>
                                                                <table class="day_cs" id="month_cs">
                                                                    <tbody>
                                                                    <tr>
                                                                        <td><a href="javascript:;">1</a></td>
                                                                        <td><a href="javascript:;">2</a></td>
                                                                        <td><a href="javascript:;">3</a></td>
                                                                        <td><a href="javascript:;">4</a></td>
                                                                        <td><a href="javascript:;">5</a></td>
                                                                        <td><a href="javascript:;">6</a></td>
                                                                        <td><a href="javascript:;">7</a></td>
                                                                        <td><a href="javascript:;">8</a></td>
                                                                        <td><a href="javascript:;">9</a></td>
                                                                        <td><a href="javascript:;">10</a></td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td><a href="javascript:;">11</a></td>
                                                                        <td><a href="javascript:;">12</a></td>
                                                                        <td><a href="javascript:;">13</a></td>
                                                                        <td><a href="javascript:;">14</a></td>
                                                                        <td><a href="javascript:;">15</a></td>
                                                                        <td><a href="javascript:;">16</a></td>
                                                                        <td><a href="javascript:;">17</a></td>
                                                                        <td><a href="javascript:;">18</a></td>
                                                                        <td><a href="javascript:;">19</a></td>
                                                                        <td><a href="javascript:;">20</a></td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td><a href="javascript:;">21</a></td>
                                                                        <td><a href="javascript:;">22</a></td>
                                                                        <td><a href="javascript:;">23</a></td>
                                                                        <td><a href="javascript:;">24</a></td>
                                                                        <td><a href="javascript:;">25</a></td>
                                                                        <td><a href="javascript:;">26</a></td>
                                                                        <td><a href="javascript:;">27</a></td>
                                                                        <td><a href="javascript:;">28</a></td>
                                                                        <td><a href="javascript:;">29</a></td>
                                                                        <td><a href="javascript:;">30</a></td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td><a href="javascript:;">31</a></td>
                                                                        <td colspan="9"></td>
                                                                    </tr>
                                                                    </tbody>
                                                                </table>
                                                            </td>
                                                        </tr>
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                            <!--/基础信息结束-->
                                            <div class="opn-btn" style="padding-left: 10px; " id="hidevalue">
                                                <input type="hidden" name="ticketid" id="ticketid" value="13">
                                                <input type="hidden" name="action" id="action" value="edit">
                                                <input type="hidden" name="spotid" id="spotid" value="9">
                                                <input type="hidden" name="pricerule" id="pricerule" value="all">
                                                <a class="normal-btn" id="btn_save" href="javascript:;">保存</a>
                                                <a class="normal-btn" href="javascript:;" id="btn_view_more" style=""
                                                   onclick="showMore()">查看报价</a>
                                            </div>
                                        </div>
                                    </dd>
                                </dl>
                            </div>
                        </div>
                    </div>
                </div>
                <input type="submit" value="提交">
            </form>
        </td>
    </tr>
    </tbody>
</table>
<script>
    $(document).ready(function () {

        var action = "edit";
        var group = "2,1,3";
        var groupArr = group.split(',');

        //生成日历
        $("input[name='starttime']").datepicker();
        $("input[name='endtime']").datepicker();

        $(".price_menu a").click(function () {

            var index = $(".price_menu a").index(this);
            var pricerule = $(this).attr("data-val");
            $("#pricerule").val(pricerule);
            $(this).siblings().removeClass('on');
            $(this).addClass('on');
            $(".price_sub .sub_item:eq(" + index + ")").show().siblings(".sub_item").hide();
        });
        if ($.inArray('1', groupArr) != -1) {
            $('.group_1').show();
            $('#childgroup').attr('checked', 'checked');
        }
        if ($.inArray('2', groupArr) != -1) {
            $('.group_2').show();
            $('#adultgroup').attr('checked', 'checked');
        }
        if ($.inArray('3', groupArr) != -1) {
            $('.group_3').show();
            $('#oldgroup').attr('checked', 'checked');
        }
        //保存
        $("#btn_save").click(function () {
            var suitname = $("#suitname").val();
            if (suitname == '') {
                ST.Util.showMsg('请输入套餐名称', 5, 1000);
                return false;
            }
            $.ajaxform({
//                url: SITEURL + "line/admin/line/ajax_suitsave",
                url: "submitCalendar.php",
                method: "POST",
                form: "#product_frm",
                dataType: 'html',
                success: function (result) {
                    var data = result;
                    if (data != 'no') {
                        $("#suitid").val(data);
                        ST.Util.showMsg('保存成功!', '4', 2000);
                        $("#btn_view_more").show();
                    }
                }
            });
        })
        //如果是修改页面
        //日历选择
        $(".choosetime").click(function () {
            WdatePicker({skin: 'whyGreen', dateFmt: 'yyyy-MM-dd', minDate: '%y-%M-%d', maxDate: '#{%y+2}-%M-%d'})
        })
        $("#week_cs td a").click(function (e) {
            var v = $(this).attr('val');
            if ($(this).hasClass('active')) {
                $("#weekval_" + v).remove();
            }
            else {
                $("#hidevalue").append("<input type='hidden' id='weekval_" + v + "' name='weekval[]' value='" + v + "'/>");
            }
            $(this).toggleClass('active');
        });
        $("#month_cs td a").click(function (e) {
            var v = $(this).text();
            v = $.trim(v);
            v = window.parseInt(v);
            if ($(this).hasClass('active')) {
                $("#monthval_" + v).remove();
            }
            else {
                $("#hidevalue").append("<input type='hidden' id='monthval_" + v + "' name='monthval[]' value='" + v + "'/>");
            }
            $(this).toggleClass('active');
        });
        $(".prop-group input:checkbox").click(
            function (e) {
                $(".group-tb tr").hide();
                $(".prop-group input:checked").each(function (index, element) {
                    var gp = $(element).val();
                    $(".group_" + gp).show();
                });
            }
        );
    });


    //查看日历报价
    function showMore() {
        var suitid = $("#suitid").val();
        var productid = $("#lineid").val();
        var width = $(window).width() - 100;
        var height = $(window).height() - 100
        var url = SITEURL + 'line/admin/calendar/index/suitid/' + suitid + '/productid/' + productid;
        ST.Util.showBox('查看报价', url, width, height);
    }

    //计算价格
    function calPrice(obj) {
        var dd = $(obj).parents('td:first');
        var tprice = 0;
        dd.find('input:text').each(function (index, element) {
            var price = parseInt($(element).val());
            if (!isNaN(price))
                tprice += price;
        });
        dd.find(".tprice").html("¥" + tprice);
    }
</script>
</body>
</html>